﻿Ext.define('app.prm.project.WeeklyView', {
    extend: 'Ext.panel.Panel',
    border: true,
    laboratoryId: 0,
    startTime: new Date(),
    bodyStyle: 'padding:5px',
    initComponent: function () {
        var me = this;
        me.items = [];
        me.callParent();
    },
    listeners: {
        afterrender: function (me) {
            //上海研发中心第一研究室 2016年32周 (2016-8-8 ~ 2016-8-14)
            App.AjaxGet('/api/services/app/summary/GetProjectWeekly?LaboratoryId=' + me.laboratoryId + "&StartTime=" + me.startTime, function (data) {
                var record = data.result;
                var str = record.isSubmit ? "概要已提交" : "概要未提交";
                me.setTitle("<a style='color:red'>" + record.laboratory + str + "</a>");

                for (var i = 0; i < record.projects.length; i++) {
                    var p = record.projects[i];
                    var panel = new Ext.panel.Panel({ border: false, style: 'margin:10px 0 0 0', title: p.name + "(" + p.projectNo + ")&nbsp;&nbsp;" + p.attachments.length + "个周报" });
                    for (var j = 0; j < p.attachments.length; j++) {
                        var att = p.attachments[j];
                        var attPanel = new Ext.panel.Panel({ border: false, html: "<a href='/api/services/app/document/GetFile?path=" + att.path + "'>" + att.name + "</a>" + "&nbsp;&nbsp;(" + att.size + "kb)" });
                        panel.add(attPanel);
                    }
                    me.add(panel);
                }
            });
        }
    }
})